from pyecharts.charts import Bar
from pyecharts import options as opts

# 数据准备
categories = ["Shirts", "Coats", "Jeans", "Boots", "Sweaters", "Pajamas"]
data1 = [5, 20, 36, 10, 75, 90]
data2 = [10, 25, 8, 60, 20, 80]

# 创建柱状图Bar实例
bar = Bar()

# 添加X轴数据
bar.add_xaxis(categories)

# 添加Y轴数据及其对应图例标签
bar.add_yaxis("商店A", data1)
bar.add_yaxis("商店B", data2)

# 设置全局配置项，添加图例（不是必须的，默认会添加）
bar.set_global_opts(legend_opts=opts.LegendOpts(is_show=True))

# 生成本地 HTML 文件
bar.render('./Files/bar_with_legend.html')
